package main

func main() {
	println(destCity([][]string{{"London", "New York"}, {"New York", "Lima"}, {"Lima", "Sao Paulo"}}))

}

/**
 *	destCity
 *	@Description:哈希表
 *	@param paths [][]string
 *	@return end string
 */
func destCity(paths [][]string) (end string) {
	n := len(paths)
	mPath := make(map[string]string, n)
	for _, path := range paths {
		mPath[path[0]] = path[1]
	}
	end = paths[0][0]
	for {
		if _, ok := mPath[end]; !ok {
			return
		}
		end = mPath[end]
	}
}
